package com.gaoyubo.service;

import com.gaoyubo.dao.CityMapper;
import com.gaoyubo.entity.City;
import com.gaoyubo.entity.Ctype;
import com.gaoyubo.entity.SearchVO;
import com.gaoyubo.entity.VO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CityServiceImpl implements CityService{
  @Autowired
  CityMapper cityMapper;
  //列表+查询+分页
  @Override
  public PageInfo getList(Integer pageNum, Integer pageSize, SearchVO searchVO) {
    PageHelper.startPage(pageNum,pageSize);
    List list = cityMapper.getList(searchVO);
    return new PageInfo(list);
  }

  @Override
  public List typeList() {
    return cityMapper.typeList();
  }

  @Override
  public void deleteById(Integer id) {
    cityMapper.deleteById(id);
  }

  @Override
  public void deleteByIds(String ids) {
    System.out.println("@@@@@"+ids);
    cityMapper.deleteByIds(ids);
  }

  @Override
  public void saveOrUpdate(VO vo) {
    if(vo.getCityId()!=null){
      cityMapper.updates(vo);
    }else{
      cityMapper.save(vo);
    }
  }

  @Override
  public City getListById(Integer id) {
    return cityMapper.getListById(id);
  }
}
